// create namespace
Ext.namespace('zr.dms');

/**
 * 主菜单
 */
zr.dms.MainMenu = function(config) {
	Ext.apply(this, config);
	zr.dms.MainMenu.superclass.constructor.call(this, {
				id : 'mainMenu',
				items : [{
							id : 'btnBack',
							cls : 'x-btn-text-icon',
							icon : 'js/back.png',
							text : '后退',
							tooltip : '后退',
							handler : this.goBack,
							scope : this
						}, {
							id : 'btnUp',
							cls : 'x-btn-text-icon',
							icon : 'js/up.png',
							text : '向上',
							tooltip : '向上',
							handler : this.goUp,
							scope : this
						}, {
							id : 'btnCreateFolder',
							cls : 'x-btn-text-icon',
							icon : 'js/folder_classic_add.png',
							text : '新建文件夹',
							tooltip : '新建文件夹',
							handler : this.showCreateFolderWindow,
							scope : this
						}, '-', {
							id : 'btnUploadFile',
							cls : 'x-btn-text-icon',
							tooltip : '上传文件',
							icon : 'js/document_letter_upload.png',
							text : '上传文件',
							handler : this.showUploadFileWindow,
							scope : this
						}, '-', {
							id : 'btnCreateFile',
							text : '在线新建文件',
							tooltip : '在线新建文件',
							icon : 'js/document_letter_add.png',
							menu : [{
										id : 'doc',
										text : 'WORD',
										icon : 'js/page_white_word.png',
										handler : this.createFile
									}, {
										id : 'xls',
										text : 'EXCEL',
										icon : 'js/page_white_excel.png',
										handler : this.createFile
									}, {
										id : 'ppt',
										text : 'PPT',
										icon : 'js/page_white_powerpoint.png',
										handler : this.createFile
									}, {
										id : 'wps',
										text : 'WPS',
										icon : 'js/page_white_word.png',
										handler : this.createFile
									}]
						}]
			});
};

Ext.extend(zr.dms.MainMenu, Ext.Toolbar, {

	/** 主控程序 */
	manager : null,
	/** 新建文件夹窗口 */
	createFolderWindow : null,
	/** 上传文件窗口 */
	uploadFileWindow : null,
	/** 复制目的文件夹id */
	targetFolderId : null,
	/** 复制源文件夹id */
	ids : null,
	/** 复制源文件name */
	names : null,
	/** 文件夹树窗口 */
	selectFolderTreeWindow : null,

	/**
	 * 退回至上一次访问的目录
	 */
	goBack : function() {
		var pathArray = this.manager.getPathArray();
		var previousPath;
		var pNode;
		var pNodeId;
		var pNodeName;
		var path;
		if (pathArray.length > 1) {
			previousPath = pathArray[pathArray.length - 2];
			pNodeId = previousPath[0];
			pNodeName = previousPath[1];
			path = previousPath[2];
			pNode = this.manager.getFolderTree().getNodeById(pNodeId);
			this.manager.getGridList().loadList(pNodeId, pNodeName);
			this.manager.getFolderTree().expandPath("/-1" + path);
			this.manager.getAddressBar().setAddress("/-1" + path,
					pNode.attributes.fullpath + '/' + pNodeName);
			pathArray.pop();
		} else if (pathArray.length = 1) {
			this.manager.getGridList().loadList("-1", "");
			this.manager.getFolderTree().expandNode("-1");
			this.manager.getAddressBar().setAddress('', '');
		} else {

		}

	},

	/**
	 * 转向上级目录
	 */
	goUp : function() {
		// var checkedArray = this.manager.getFolderTree().getChecked();
		var currentCatId = this.manager.getGridList().getCurrentCatId();
		// this.manager.getFolderTree()
		if (currentCatId == "-1") {

		} else {
			// 导航树中当前节点的父节点
			var parentNode = this.manager.getFolderTree()
					.getNodeById(currentCatId).parentNode;
			var pNodeId = parentNode.id;
			var pNodeName = parentNode.text;
			if (pNodeId == "-1") {
				this.manager.getGridList().loadList(pNodeId, pNodeName);
				this.manager.getFolderTree().expandNode(pNodeId);
				this.manager.getAddressBar().setAddress('', '');
			} else {
				this.manager.getGridList().loadList(pNodeId, pNodeName);
				this.manager.getFolderTree().expandNode(pNodeId);
				this.manager.getFolderTree().fireEvent("click", parentNode);
			}

		}
	},

	/**
	 * 显示新建单位窗口
	 */
	showCreateFolderWindow : function() {
		if (this.createFolderWindow == null) {
			this.createFolderWindow = new zr.dms.CreateFolderWindow({
						okHandler : function(dialog, e) {
							var catId = this.manager.getGridList()
									.getCurrentCatId();
							this.manager.getFolderTree().reloadNode(catId);
							this.manager.getGridList().reloadList();
							this.createFolderWindow.hide();
						},
						scope : this
					});
		}
		var catId = this.manager.getGridList().getCurrentCatId();
		var catName = this.manager.getGridList().getCurrentCatName();
		this.createFolderWindow.showWindow(catId, catName, 'addNew', null);
	},

	/**
	 * 显示文件夹编辑窗口
	 */
	showEditFolderWindow : function() {
		if (this.createFolderWindow == null) {
			this.createFolderWindow = new zr.dms.CreateFolderWindow({
						okHandler : function(dialog, e) {
							var catId = this.manager.getGridList()
									.getCurrentCatId();
							this.manager.getFolderTree().reloadNode(catId);
							this.manager.getGridList().reloadList();
							this.createFolderWindow.hide();
						},
						scope : this
					});
		}

		var catId = this.manager.getGridList().getCurrentCatId();
		var catName = this.manager.getGridList().getCurrentCatName();
		var m = this.manager.getGridList().getSelectionModel().getSelections();
		if (m.length == 1) {
			var record = this.manager.getGridList().getSelectionModel()
					.getSelected();
			var objkey = record.data.objkey;
			if (objkey == "FILEINFO") {
				Ext.MessageBox.alert('提示', '请先选中一个要编辑的文件夹！');
			} else {
				this.createFolderWindow.showWindow(catId, catName, 'edit',
						record);
			}

		} else {
			Ext.MessageBox.alert('提示', '请先选中一个要编辑的文件夹！');
		}

	},

	/**
	 * 显示上传文件窗口
	 */
	showUploadFileWindow : function() {
		var catId = this.manager.getGridList().getCurrentCatId();
		if (catId == "") {
			catId = "-1";
		}
		var catName = this.manager.getGridList().getCurrentCatName();
		doUploadFile(catId, this.manager.getGridList());
	},
	/**
	 * 在线新建文件
	 */
	createFile : function(btn) {
		var createDocWindow = new zr.dms.createDocWindow();
		var catid = Ext.getCmp("fileListGrid").getCurrentCatId();
		createDocWindow.showWindow(catid, btn.id);
	},

	/**
	 * 删除选定的文件夹、文件
	 */
	doDel : function() {
		var scope = this;
		var grid = this.manager.getGridList();
		var tree = this.manager.getFolderTree();
		var m = grid.getSelectionModel().getSelections();
		var ids;
		if (m.length > 0) {
			Ext.MessageBox.confirm('确认', '确认要删除所选中的内容吗?', doDelAction, this);
		} else {
			Ext.MessageBox.alert('错误', '请选中待删除的文件夹或文件！');
		}

		function doDelAction(btn) {
			if (btn == 'yes') {
				var m = grid.getSelectionModel().getSelections();
				for (var i = 0, len = m.length; i < len; i++) {
					// ids.push(m[i].get('objid'));
					if (i == 0) {
						ids = m[i].get('objid');
					} else {
						ids += ',' + m[i].get('objid');
					}
				}
				Ext.Ajax.request({
							url : context + '/app/dms.do?method=delete',
							waitMsg : '操作处理中...',
							method : 'POST',
							params : {
								'ids' : ids
							},
							success : function(form, action) {
								grid.reloadList();
								tree.reloadNode(grid.getCurrentCatId());
								Ext.Msg.alert('操作结束', '删除成功');
								// var obj =
								// Ext.util.JSON.decode(form.responseText); //
								// 返回的结果
								// alert(obj.info);
							},
							failure : function() {
								Ext.Msg.alert('', '删除失败');
							}
						});
			}
		}

	},
	/**
	 * 点击“复制”按钮后显示目录树window，供用户选择目标文件夹
	 */
	showFolderTreeWindow : function(btn) {

		if (this.selectFolderTreeWindow == null) {
			this.selectFolderTreeWindow = new zr.dms.selectFolderTreeWindow({
						okHandler : function(dialog, e) {
							var tragetId = this.selectFolderTreeWindow.tragetId;
							this.manager.getFolderTree().reloadNode(tragetId);
							this.manager.getGridList().reloadList();
							this.selectFolderTreeWindow.hide();
						},
						scope : this
					});
		}

		// var scope = this;
		var grid = this.manager.getGridList();
		var m = grid.getSelectionModel().getSelections();
		for (var i = 0, len = m.length; i < len; i++) {
			// ids.push(m[i].get('objid'));
			if (i == 0) {
				this.ids = m[i].get('objid');
				this.names = m[i].get('filename');
			} else {
				this.ids += ',' + m[i].get('objid');
				this.names += ',' + m[i].get('filename');
			}
		}

		if (m.length > 0) {
			if (btn.opType == 'copy') {
				this.selectFolderTreeWindow.showWindow(this.ids, this.names,
						'copy');
			} else if ((btn.opType == 'cut')) {
				this.selectFolderTreeWindow.showWindow(this.ids, this.names,
						'cut');
			};

		} else {
			Ext.MessageBox.alert('错误', '请先选中需要复制的文件夹或文件！');
		}

	},

	/**
	 * 刷新当前显示页面
	 */
	doReload : function() {
		var catId = this.manager.getGridList().getCurrentCatId();
		this.manager.getGridList().reloadList();
		var tree = this.manager.getFolderTree();
		var node = tree.getNodeById(catId);
		var path = node.getPath();
		this.manager.getFolderTree().reloadNode('-1', function() {
					tree.expandPath(path);
				});

	}

});


/**
 * "共享文档"工具栏
 */
zr.dms.ShareDocMenu = function(config) {
	Ext.apply(this, config);
	zr.dms.ShareDocMenu.superclass.constructor.call(this, {
				id : 'shareDocMenu',
				items : [{
							id : 'sdBtnBack',
							cls : 'x-btn-text-icon',
							icon : 'js/back.png',
							text : '后退',
							tooltip : '后退',
							handler : this.goBack,
							scope : this
						}, {
							id : 'sdBtnUp',
							cls : 'x-btn-text-icon',
							icon : 'js/up.png',
							text : '向上',
							tooltip : '向上',
							handler : this.goUp,
							scope : this
						}]
			});
};


Ext.extend(zr.dms.ShareDocMenu, Ext.Toolbar, {

	/** 主控程序 */
	manager : null,
	/** 新建文件夹窗口 */
	createFolderWindow : null,
	/** 上传文件窗口 */
	uploadFileWindow : null,
	/** 复制目的文件夹id */
	targetFolderId : null,
	/** 复制源文件夹id */
	ids : null,
	/** 复制源文件name */
	names : null,
	/** 文件夹树窗口 */
	selectFolderTreeWindow : null,

	/**
	 * 退回至上一次访问的目录
	 */
	goBack : function() {
		var pathArray = this.manager.getSharePathArray();
		var previousPath;
		var pNode;
		var pNodeId;
		var pNodeName;
		var path;
		if (pathArray.length > 1) {
			previousPath = pathArray[pathArray.length - 2];
			pNodeId = previousPath[0];
			pNodeName = previousPath[1];
			path = previousPath[2];
			pNode = this.manager.getSharedFolderTreePanel().getNodeById(pNodeId);
			this.manager.getShareGrid().loadList(pNodeId, pNodeName);
			this.manager.getSharedFolderTreePanel().expandPath("/-1" + path);
			pathArray.pop();
		} else if (pathArray.length = 1) {
			this.manager.getShareGrid().loadList("-1", "");
			this.manager.getSharedFolderTreePanel().expandNode("-1");
		} else {

		}

	},

	/**
	 * 转向上级目录
	 */
	goUp : function() {
		var currentCatId = this.manager.getShareGrid().getCurrentCatId();
		if (currentCatId == "-1") {

		} else {
			// 导航树中当前节点的父节点
			var parentNode = this.manager.getSharedFolderTreePanel()
					.getNodeById(currentCatId).parentNode;
			var pNodeId = parentNode.id;
			var pNodeName = parentNode.text;
			if (pNodeId == "-1") {
				this.manager.getShareGrid().loadList(pNodeId, pNodeName);
				this.manager.getSharedFolderTreePanel().expandNode(pNodeId);
			} else {
				this.manager.getShareGrid().loadList(pNodeId, pNodeName);
				this.manager.getSharedFolderTreePanel().expandNode(pNodeId);
				}

		}
	},


	/**
	 * 删除选定的文件夹、文件
	 */
	doDel : function() {
		var scope = this;
		var grid = this.manager.getGridList();
		var tree = this.manager.getFolderTree();
		var m = grid.getSelectionModel().getSelections();
		var ids;
		if (m.length > 0) {
			Ext.MessageBox.confirm('确认', '确认要删除所选中的内容吗?', doDelAction, this);
		} else {
			Ext.MessageBox.alert('错误', '请选中待删除的文件夹或文件！');
		}

		function doDelAction(btn) {
			if (btn == 'yes') {
				var m = grid.getSelectionModel().getSelections();
				for (var i = 0, len = m.length; i < len; i++) {
					// ids.push(m[i].get('objid'));
					if (i == 0) {
						ids = m[i].get('objid');
					} else {
						ids += ',' + m[i].get('objid');
					}
				}
				Ext.Ajax.request({
							url : context + '/app/dms.do?method=delete',
							waitMsg : '操作处理中...',
							method : 'POST',
							params : {
								'ids' : ids
							},
							success : function(form, action) {
								grid.reloadList();
								tree.reloadNode(grid.getCurrentCatId());
								Ext.Msg.alert('操作结束', '删除成功');
								// var obj =
								// Ext.util.JSON.decode(form.responseText); //
								// 返回的结果
								// alert(obj.info);
							},
							failure : function() {
								Ext.Msg.alert('', '删除失败');
							}
						});
			}
		}

	},
	/**
	 * 点击“复制”按钮后显示目录树window，供用户选择目标文件夹
	 */
	showFolderTreeWindow : function(btn) {

		if (this.selectFolderTreeWindow == null) {
			this.selectFolderTreeWindow = new zr.dms.selectFolderTreeWindow({
						okHandler : function(dialog, e) {
							var tragetId = this.selectFolderTreeWindow.tragetId;
							this.manager.getFolderTree().reloadNode(tragetId);
							this.manager.getGridList().reloadList();
							this.selectFolderTreeWindow.hide();
						},
						scope : this
					});
		}

		// var scope = this;
		var grid = this.manager.getGridList();
		var m = grid.getSelectionModel().getSelections();
		for (var i = 0, len = m.length; i < len; i++) {
			// ids.push(m[i].get('objid'));
			if (i == 0) {
				this.ids = m[i].get('objid');
				this.names = m[i].get('filename');
			} else {
				this.ids += ',' + m[i].get('objid');
				this.names += ',' + m[i].get('filename');
			}
		}

		if (m.length > 0) {
			if (btn.opType == 'copy') {
				this.selectFolderTreeWindow.showWindow(this.ids, this.names,
						'copy');
			} else if ((btn.opType == 'cut')) {
				this.selectFolderTreeWindow.showWindow(this.ids, this.names,
						'cut');
			};

		} else {
			Ext.MessageBox.alert('错误', '请先选中需要复制的文件夹或文件！');
		}

	}

});




/**
 * 选中单个文件时的右键上下文菜单
 */
zr.dms.ContextMenu4SingleFolder = function(config) {

	Ext.apply(this, config);
	zr.dms.ContextMenu4SingleFolder.superclass.constructor.call(this, {
				id : 'contextMenu4SingleFolder',
				items : [{
							id : 'ctxMenu4SfolderOpen',
							text : '打开',
							handler : this.openFolder,
							scope : this
						}, {
							id : 'ctxMenu4SfolderRename',
							text : '重命名',
							handler : this.showEditFolderWindow,
							scope : this
						}, '-', {
							id : 'ctxMenu4SfolderShare',
							cls : 'x-btn-text-icon',
							icon : 'js/documents_share.png',
							text : '共享设置',
							handler : this.showSharedSet,
							scope : this
						}, '-', {
							id : 'ctxMenu4SfolderCopy',
							text : '复制',
							icon : 'js/document_copy.png',
							handler : this.showFolderTreeWindow,
							opType : 'copy',
							scope : this
						}, {
							id : 'ctxMenu4SfolderCut',
							text : '剪切',
							icon : 'js/document_copy.png',
							handler : this.showFolderTreeWindow,
							opType : 'cut',
							scope : this
						}, {
							id : 'ctxMenu4SfolderDelete',
							icon : 'js/documents_remove.png',
							text : '删除',
							handler : this.doDel,
							scope : this
						}, '-', {
							id : 'ctxMenu4SfolderAttribute',
							cls : 'x-btn-text-icon',
							text : '属性',
							tooltip : '编辑文件夹属性',
							handler : this.editFolderProp,
							scope : this
						}]
			});
};

Ext.extend(zr.dms.ContextMenu4SingleFolder, Ext.menu.Menu, {
			/** 主控菜单 */
			mainMenu : null,
			/** 鼠标当前所在行id */
			activeId : '',

			openFolder : function() {
				this.mainMenu.manager.getGridList().fireEvent("rowdblclick",
						this.mainMenu.manager.getGridList());
			},
			/**
			 * 复制/剪切操作
			 */
			showFolderTreeWindow : function(btn) {
				this.mainMenu.showFolderTreeWindow(btn);
			},

			/**
			 * 删除操作
			 */
			doDel : function() {
				this.mainMenu.doDel();
			},

			/**
			 * 共享设置
			 */
			showSharedSet : function() {
				sharedset(this.mainMenu.manager.getGridList(), 'folder');
			},

			/**
			 * 文件夹属性
			 */
			editFolderProp : function() {
				var grid = this.mainMenu.manager.getGridList();
				var folderTree = this.mainMenu.manager.getFolderTree();
				var m = grid.getSelectionModel().getSelections();
				if (m.length > 0) {
					var oid = m[0].get('objid');
					var id = m[0].get('id');
					var pNode = folderTree.getNodeById(id).parentNode;
					editAttribute(oid,pNode.id,grid,folderTree);
				}
			},

			/**
			 * 删除
			 */
			doDel : function() {
				this.mainMenu.doDel();
			},

			showEditFolderWindow : function() {
				this.mainMenu.showEditFolderWindow();
			},

			/**
			 * 设置当前鼠标点选的行
			 */
			setActiveId : function(id) {
				this.activeId = id;
			},

			getActiveId : function() {
				return this.activeId;
			}

		});

/**
 * 选中单个文件时的右键上下文菜单
 */
zr.dms.ContextMenu4SingleFile = function(config) {
	Ext.apply(this, config);
	zr.dms.ContextMenu4SingleFile.superclass.constructor.call(this, {
				id : 'contextMenu4SingleFile',
				items : [{
							id : 'ctxMenu4SfileEdit',
							text : '在线编辑',
							handler : this.onlineEdit,
							scope : this
						}, {
							id : 'ctxMenu4SfileDownload',
							text : '下载',
							handler : this.downLaod,
							scope : this
						}, '-', {
							id : 'ctxMenu4SfileShare',
							cls : 'x-btn-text-icon',
							icon : 'js/documents_share.png',
							text : '共享设置',
							handler : this.showSharedSet,
							scope : this
						}, '-', {
							id : 'ctxMenu4SfileCopy',
							text : '复制',
							icon : 'js/document_copy.png',
							handler : this.showFolderTreeWindow,
							opType : 'copy',
							scope : this
						}, {
							id : 'ctxMenu4SfileCut',
							text : '剪切',
							icon : 'js/document_copy.png',
							handler : this.showFolderTreeWindow,
							opType : 'cut',
							scope : this
						}, {
							id : 'ctxMenu4SfileDelete',
							icon : 'js/documents_remove.png',
							text : '删除',
							handler : this.doDel,
							scope : this
						}, '-', {
							id : 'ctxMenu4SfileAttribute',
							cls : 'x-btn-text-icon',
							icon : 'js/folder_classic_edit.png',
							text : '属性',
							tooltip : '编辑文件属性',
							handler : this.editFileProp,
							scope : this
						}]
			});
};

Ext.extend(zr.dms.ContextMenu4SingleFile, Ext.menu.Menu, {
			/** 主控菜单 */
			mainMenu : null,
			/** 鼠标当前所在行id */
			activeId : '',

			/**
			 * 打开在线编辑窗口
			 */
			onlineEdit : function() {
				var grid = this.mainMenu.manager.getGridList();
				var m = grid.getSelectionModel().getSelections();
				if (m.length > 0) {
					var fileId = m[0].get('id');
					var objId = m[0].get('objid');
					var fileType = m[0].get('style');
					var OnlineEditWindow = new zr.dms.OnlineEditWindow({
								fileType : fileType,
								purviewArray : ''
							});
					OnlineEditWindow.showWindow(objId, fileId, grid
									.getCurrentCatId());

				}

			},

			/**
			 * 下载操作
			 */
			downLaod : function() {
				var grid = this.mainMenu.manager.getGridList();
				var m = grid.getSelectionModel().getSelections();

				if (m.length > 0) {
					var fid = m[0].get('id');
					var url = context
							+ '/app/dms.do?method=download&fk_annex_id=' + fid
							+ '&fileType=latestversion';

					if (m[0].get('filesize') > dlfilesize) {
						Ext.MessageBox
								.confirm(
										'文档下载提示',
										'您要下载的文档较大,系统会自动将文档下载到您的ftp下载目录中,然后您再通过ftp工具将文件下载到本地',
										function(btn) {
											if (btn == 'yes') {
												Ext.get('dmsdldfrm').dom.src = url;
											}
										});
					} else {
						Ext.get('dmsdldfrm').dom.src = url;
					}

				}

			},

			/**
			 * 复制/剪切操作
			 */
			showFolderTreeWindow : function(btn) {
				this.mainMenu.showFolderTreeWindow(btn);
			},

			/**
			 * 删除操作
			 */
			doDel : function() {
				this.c.doDel();
			},

			/**
			 * 共享设置
			 */
			showSharedSet : function() {
				sharedset(this.mainMenu.manager.getGridList(), 'file');
			},

			/**
			 * 文件属性
			 */
			editFileProp : function() {
				var grid = this.mainMenu.manager.getGridList();
				var m = grid.getSelectionModel().getSelections();
				if (m.length > 0) {
					var oid = m[0].get('objid');
					editAttribute(oid,null,grid,null);
				}
			
			},

			/**
			 * 删除
			 */
			doDel : function() {
				this.mainMenu.doDel();
			},

			showEditFolderWindow : function() {
				this.mainMenu.showEditFolderWindow();
			},

			/**
			 * 设置当前鼠标点选的行
			 */
			setActiveId : function(id) {
				this.activeId = id;
			},

			getActiveId : function() {
				return this.activeId;
			}

		});

/**
 * 选中多项时的右键上下文菜单
 */
zr.dms.ContextMenu4Mix = function(config) {

	Ext.apply(this, config);
	zr.dms.ContextMenu4Mix.superclass.constructor.call(this, {
				id : 'contextMenu4Mix',
				items : [{
							id : 'ctxMenu4MixCopy',
							text : '复制',
							icon : 'js/document_copy.png',
							handler : this.showFolderTreeWindow,
							opType : 'copy',
							scope : this
						}, {
							id : 'ctxMenu4MixCut',
							text : '剪切',
							icon : 'js/document_copy.png',
							handler : this.showFolderTreeWindow,
							opType : 'cut',
							scope : this
						}, {
							id : 'ctxMenu4MixDelete',
							icon : 'js/documents_remove.png',
							text : '删除',
							handler : this.doDel,
							scope : this
						}, '-', {
							id : 'ctxMenu4MixEditInfo',
							cls : 'x-btn-text-icon',
							icon : 'js/documents_share.png',
							text : '共享设置',
							handler : this.showSharedSet,
							scope : this
						}]
			});
};

Ext.extend(zr.dms.ContextMenu4Mix, Ext.menu.Menu, {
			/** 主控菜单 */
			mainMenu : null,
			/** 鼠标当前所在行id */
			activeId : '',

			/**
			 * 复制/剪切操作
			 */
			showFolderTreeWindow : function(btn) {
				this.mainMenu.showFolderTreeWindow(btn);
			},

			/**
			 * 删除操作
			 */
			doDel : function() {
				this.mainMenu.doDel();
			},


			/**
			 * 共享设置
			 */
			showSharedSet : function() {
				sharedset(this.mainMenu.manager.getGridList(), 'remix');
			},

			/**
			 * 设置当前鼠标点选的行
			 */
			setActiveId : function(id) {
				this.activeId = id;
			},

			getActiveId : function() {
				return this.activeId;
			}

		});
		
zr.dms.CtxMenu4Myshare = function(config){


	Ext.apply(this, config);
	zr.dms.CtxMenu4Myshare.superclass.constructor.call(this, {
				id : 'ctxMenu4Myshare',
				items : [ {
							id : 'ctxMenu4MSShare',
							cls : 'x-btn-text-icon',
							icon : 'js/documents_share.png',
							text : '共享设置',
							handler : this.showSharedSet,
							scope : this
						}, {
							id : 'ctxMenu4SfileAttribute',
							cls : 'x-btn-text-icon',
							icon : 'js/folder_classic_edit.png',
							text : '属性',
							tooltip : '编辑文件属性',
							handler : this.editFileProp,
							scope : this
						}]
			});

};

Ext.extend(zr.dms.CtxMenu4Myshare, Ext.menu.Menu, {
			/** 主控菜单 */
			mainMenu : null,
			/** 鼠标当前所在行id */
			activeId : '',

			/**
			 * 共享设置
			 */
			showSharedSet : function() {
				var grid = this.mainMenu.manager.getMyShareGrid();
				var sm = grid.getSelectionModel();
				if(sm.hasSelection()) {
				var m = sm.getSelections();
				var objkey = m[0].get('objkey');
				if(objkey == 'FOLDER' ) {
					sharedset(grid, 'folder');
				}else{
					sharedset(grid, 'file');
				}
				
				}
			},
			
			/**
			 * 文件属性
			 */
			editFileProp : function() {
				var grid = this.mainMenu.manager.getMyShareGrid();
				var m = grid.getSelectionModel().getSelections();
				if (m.length > 0) {
					var oid = m[0].get('objid');
					editAttribute(oid,null,grid,null);
				}
			
			},
			/**
			 * 设置当前鼠标点选的行
			 */
			setActiveId : function(id) {
				this.activeId = id;
			},

			getActiveId : function() {
				return this.activeId;
			}

		});
		
		
/**
 * 共享区gridpanel的工具栏
 * 
 * @param {}
 *            config
 */
zr.dms.WorkSpaceMenu = function(config) {
	Ext.apply(this, config);
	zr.dms.WorkSpaceMenu.superclass.constructor.call(this, {
				id : 'workSpaceMenu',
				items : [{
							id : 'wsbtnCopy',
							cls : 'x-btn-text-icon',
							icon : 'js/document_copy.png',
							text : '复制',
							tooltip : '复制选中项',
							handler : this.showFolderTreeWindow,
							scope : this
						}]
			});
};

Ext.extend(zr.dms.WorkSpaceMenu, Ext.Toolbar, {

	/** 主控程序 */
	manager : null,
	/** 复制目的文件夹id */
	targetFolderId : null,
	/** 复制源文件夹id */
	ids : null,
	/** 复制源文件name */
	names : null,
	/** 文件夹树窗口 */
	selectFolderTreeWindow : null,

	/**
	 * 点击“复制”按钮后显示目录树window，供用户选择目标文件夹
	 */
	showFolderTreeWindow : function() {
		if (this.selectFolderTreeWindow == null) {
			this.selectFolderTreeWindow = new zr.dms.selectFolderTreeWindow({
						okHandler : function(dialog, e) {
							var tragetId = this.selectFolderTreeWindow.tragetId;
							this.manager.getFolderTree().reloadNode(tragetId);
							this.manager.getGridList().reloadList();
							this.selectFolderTreeWindow.hide();
						},
						scope : this
					});
		}

		// var scope = this;
		var grid = this.manager.getWorkSpaceGrid();
		var m = grid.getSelectionModel().getSelections();
		for (var i = 0, len = m.length; i < len; i++) {
			// ids.push(m[i].get('objid'));
			if (i == 0) {
				this.ids = m[i].get('objid');
				this.names = m[i].get('filename');
			} else {
				this.ids += ',' + m[i].get('objid');
				this.names += ',' + m[i].get('filename');
			}
		}
		if (m.length > 0) {
			this.selectFolderTreeWindow
					.showWindow(this.ids, this.names, 'copy');
		} else {
			Ext.MessageBox.alert('错误', '请先选中需要复制的文件夹或文件！');
		}

	},

	/**
	 * 刷新当前显示页面
	 */
	doReload : function() {
		var catId = this.manager.getGridList().getCurrentCatId();
		this.manager.getGridList().reloadList();
		var tree = this.manager.getFolderTree();
		var node = tree.getNodeById(catId);
		var path = node.getPath();
		this.manager.getFolderTree().reloadNode('-1', function() {
					tree.expandPath(path);
				});

	}

});

/**
 * 上传文件 弹出新建文件页面
 */
function doUploadFile(currentfolderid, listGrid) {

	var uploadWin = new Ext.Window({
				title : '文件上传',
				// closeAction : 'hide',
				width : 700,
				height : 300,
				resizable : false,
				modal : true,
				html : '<iframe src=' + context
						+ '/app/fileupload/index.jsp?currentfolderid='
						+ currentfolderid
						+ ' width="100%" height="100%"></iframe>',
				listeners : {
					"beforedestroy" : function(obj) {
						listGrid.reloadList();
						// obj.show();
					}
				}
			});

	uploadWin.show();

}


function downLoad() {
	var url = context + "/app/dms/js/WebOffice_Setup.rar";
	Ext.get('dmsdldfrm').dom.src = url;
};

/**
 * 复制文件时选择目的文件夹窗口
 * 
 * @param {}
 *            config
 */
zr.dms.selectFolderTreeWindow = function(config) {
	this.folderTree = new Ext.tree.TreePanel({
				height : 400,
				width : 300,
				useArrows : true,
				autoScroll : true,
				animate : true,
				enableDD : false,
				containerScroll : true,
				rootVisible : true,
				frame : true,
				root : new Ext.tree.AsyncTreeNode({
							text : '我的文档',
							id : '-1',
							expanded : true,
							checked : false
						}),
				loader : new Ext.tree.TreeLoader({
							dataUrl : context + '/app/dms.do?method=treeNodes',
							requestMethod : 'Post',
							baseAttrs : {
								uiProvider : Ext.tree.TreeCheckNodeUI
							} // 使用扩展，使其支持单选
						}),
				checkModel : 'single'
			});

	Ext.apply(this, config);
	zr.dms.selectFolderTreeWindow.superclass.constructor.call(this, {
				id : 'selectFolderTreeWindow',
				title : '目标文件夹...',
				closeAction : 'hide',
				layout : 'fit',
				width : 300,
				height : 400,
				resizable : true,
				modal : true,
				items : this.folderTree,
				buttons : [{
							text : '确定',
							handler : function(button, e) {
								if (this.eventType == 'copy') {
									this.doCopy(e);
								} else {
									this.doCut(e);
								}
								this.hide();
							},
							scope : this
						}, {
							text : '取消',
							handler : function(button, e) {
								// this.resetInput();
								this.fireEvent('cancelClicked', this, e);
								if (this.cancelHandler) {
									this.cancelHandler.call(this.scope || this,
											this, e);
								} else {
									this.hide();
								}
							},
							scope : this
						}],
				listeners : {
					'hide' : function(node, checked) {
						var checkedArray = this.folderTree.getChecked();
						if (checkedArray.length > 0) {
							checkedArray[0].getUI().checkbox.checked = false;

						}
						this.folderTree.collapseAll();
						this.folderTree.getRootNode().expand();

					}
				}
			});

};

Ext.extend(zr.dms.selectFolderTreeWindow, Ext.Window, {

			/** 确定按钮事件处理器 */
			okHandler : null,
			/** 取消按钮事件处理器 */
			cancelHandler : null,
			/** 事件触发时对象的工作域 */
			scope : null,
			/** 要复制对象的id */
			ids : null,
			/** 要复制对象的name */
			names : null,
			/** 操作类型 复制/剪切 */
			eventType : null,

			/** 目标文件夹id */
			tragetId : null,
			/** 显示窗口 */
			showWindow : function(ids, names, eventType) {
				this.ids = ids;
				this.names = names;
				this.eventType = eventType;
				this.show();
			},

			/**
			 * 复制所选项
			 * 
			 * @param {}
			 *            event
			 */
			doCopy : function(event) {
				var selNodes = this.folderTree.getChecked();
				if (selNodes.length == 0) {
					Ext.Msg.alert('提示', '请选择目标文件夹');
					return false;
				}
				var tragetId = selNodes[0].id;
				this.tragetId = tragetId;
				var ids = this.ids;
				var names = this.names;
				Ext.Ajax.request({
							url : context + '/app/dms.do?method=copy',
							waitMsg : '操作处理中...',
							method : 'POST',
							params : {
								'ids' : ids,
								'names' : names,
								'targetId' : tragetId
							},
							scope : this,
							success : function(form, action) {
								var obj = Ext.util.JSON
										.decode(form.responseText);
								var result = obj.success + "";
								result = result.replace(/^\s+|\s+$/g, "");
								if (result == "true") {
									Ext.Msg.alert('操作结束', '复制成功');
									this.fireEvent('okClicked', this);
									if (this.okHandler) {
										this.okHandler.call(this.scope || this,
												this, event);
									} else {
										this.hide();
									}
								} else {

									Ext.Msg.alert('复制失败', obj.errors.errormsg);
								}

							},
							failure : function() {
								Ext.Msg.alert('复制失败', '发生错误');
							}
						});

			},

			/**
			 * 剪切所选项
			 * 
			 * @param {}
			 *            event
			 */
			doCut : function(event) {
				var selNodes = this.folderTree.getChecked();
				if (selNodes.length == 0) {
					Ext.Msg.alert('提示', '请选择目标文件夹');
					return false;
				}
				var tragetId = selNodes[0].id;
				this.tragetId = tragetId;
				var ids = this.ids;
				var names = this.names;
				Ext.Ajax.request({
							url : context + '/app/dms.do?method=cut',
							waitMsg : '操作处理中...',
							method : 'POST',
							params : {
								'ids' : ids,
								'names' : names,
								'targetId' : tragetId
							},
							scope : this,
							success : function(form, action) {
								var obj = Ext.util.JSON
										.decode(form.responseText);
								var result = obj.success + "";
								result = result.replace(/^\s+|\s+$/g, "");
								if (result == "true") {
									Ext.Msg.alert('操作结束', '剪切成功');
									this.fireEvent('okClicked', this);
									if (this.okHandler) {
										this.okHandler.call(this.scope || this,
												this, event);
									} else {
										this.hide();
									}
								} else {

									Ext.Msg.alert('剪切失败', obj.errors.errormsg);
								}

							},
							failure : function() {
								Ext.Msg.alert('剪切失败', '发生错误');
							}
						});

			},

			// private
			initComponent : function() {
				zr.dms.selectFolderTreeWindow.superclass.initComponent
						.call(this);
				this.addEvents(
						/**
						 * @event okClicked 当确定按钮被点击时触发
						 * @param {zr.dms.selectFolderTreeWindow}
						 *            this
						 */
						'okClicked',
						/**
						 * @event okClicked 当取消按钮被点击时触发
						 * @param {zr.dms.selectFolderTreeWindow}
						 *            this
						 */
						'cancelClicked');
			}

		});

/**
 * 在线新建文档窗口
 * 
 * @param {}
 *            config
 */
zr.dms.createDocWindow = function(config) {
	var objHtml = "<object id='WebOfficeObj' height='100%' width='100%' style='LEFT: 0px; TOP: 0px'  classid='clsid:E77E049B-23FC-4DB8-B756-60529A35FAD5' codebase='"
			+ context + "/js/weboffice_v6.0.5.0.cab#Version=6,0,5,0'>";
	objHtml += "<param name='TitlebarColor' value='7898C2'/><param name='_ExtentX' value='6350'><param name='_ExtentY' value='6350'>";
	objHtml += "</object>";

	this.tb = new Ext.Toolbar({
				id : 'toolbar',
				enableOverflow : true,
				items : [{
							text : '打印',
							iconCls : 'print',
							handler : function() {
								var webObj = document
										.getElementById("WebOfficeObj");
								webObj.PrintDoc(1);
							}
						}, '-', {
							text : '保存',
							iconCls : 'save',
							scrop : this,
							handler : this.handleSave
						}, '-', {
							text : '返回',
							iconCls : 'back',
							scrop : this,
							handler : this.handleBack
						}, '-', '文档名称：', new Ext.form.TextField({
									id : 'filename',
									width : 300,
									fieldLabel : '文档名称',
									blankText : '请定义文档名称',
									name : 'filename'
								}),'-','<a title=\"若在线编辑控件未自动安装请点击下载并安装\" onclick=\"downLoad();\" href=\'javascript:void(0)\'>下载控件</a>']
			});
	Ext.apply(this, config);
	zr.dms.createDocWindow.superclass.constructor.call(this, {
		id : 'createDocWindow',
		closeAction : 'close',
		maximizable : true,
		layout : 'fit',
		width : 1000,
		height : 600,
		modal : true,
		title : '在线编辑',
		tbar : this.tb,
		html : objHtml
			// buttons : []
		});
};

Ext.extend(zr.dms.createDocWindow, Ext.Window, {
			/** 当前所在目录id */
			currentfolderid : null,
			/** 文件表记录id */
			fileId : null,
			/** 文件对象id */
			objId : null,
			/** 文件类型 */
			fileType : null,
			/** 确定按钮事件处理器 */
			okHandler : null,
			/** 取消按钮事件处理器 */
			cancelHandler : null,
			/** 事件触发时对象的工作域 */
			scope : null,

			/**
			 * 显示窗口
			 */
			showWindow : function(currentfolderid, fileType) {
				this.currentfolderid = currentfolderid;
				this.fileType = fileType;
				this.show();
				document.all.WebOfficeObj.ShowToolBar = false;
				document.all.WebOfficeObj.OptionFlag |= 128;
				document.all.WebOfficeObj.LoadOriginalFile("", fileType);
			},

			/**
			 * 处理“保存”按钮点击事件
			 */
			handleSave : function() {
				var objId = Ext.getCmp("createDocWindow").objId;
				var fileId = Ext.getCmp("createDocWindow").fileId;
				if (objId == null) {
					Ext.getCmp("createDocWindow").add();
				} else {
					Ext.getCmp("createDocWindow").update(fileId);
					// this.update();
				}
			},
			/**
			 * 新增记录
			 * 
			 * @param {}
			 *            action
			 * @return {Boolean}
			 */
			add : function(action) {

				try {
					var filename = Ext.getCmp("filename").getValue();
					if (filename == "") {
						alert("请定义文档名称");
						return false;
					}
					var fileId = Ext.getCmp("createDocWindow").fileId;
					var catid = Ext.getCmp("fileListGrid").getCurrentCatId();
					if (catid == "") {
						catid = "-1";
					}
					var webObj = document.getElementById("WebOfficeObj");
					webObj.OptionFlag &= 0xff7f;
					// 初始化Http引擎
					webObj.HttpInit();
					// 添加相应的Post元素
					webObj.HttpAddPostString("filename", encodeURI(filename));
					webObj.HttpAddPostString("currentfolderid", catid);
					// var fileType = Ext.getCmp("createDocWindow").fileType;
					// webObj.HttpAddPostString("DocType",fileType);
					webObj.HttpAddPostCurrFile("DocContent", "");
					var returnValue = webObj.HttpPost(uploadContext
							+ '/app/fileupload.do?method=upload'); // 判断上传是否成功
					var obj = Ext.util.JSON.decode(returnValue);
					var objId = obj.list[0].objId;
					var fileId = obj.list[0].fileId;
					Ext.getCmp("createDocWindow").objId = objId;
					Ext.getCmp("createDocWindow").fileId = fileId;
					if ("true" == obj.success) {
						alert("文件保存成功");
						Ext.getCmp("fileListGrid").reloadList();
					} else
						alert("文件保存失败");
				} catch (e) {
					alert("异常\r\nError:" + e + "\r\nError Code:" + e.number
							+ "\r\nError Des:" + e.description);
				}
			},

			update : function(fileId) {

				try {
					var filename = Ext.getCmp("filename").getValue();
					if (filename == "") {
						alert("请定义文档名称");
						return false;
					}
					var catid = Ext.getCmp("fileListGrid").getCurrentCatId();
					if (catid == "") {
						catid = "-1";
					}
					var webObj = document.getElementById("WebOfficeObj");
					webObj.OptionFlag &= 0xff7f;
					// 初始化Http引擎
					webObj.HttpInit();
					// 添加相应的Post元素
					webObj.HttpAddPostString("filename", encodeURI(filename));
					webObj.HttpAddPostString("currentfolderid", catid);
					webObj.HttpAddPostString("fileId", fileId);
					webObj.HttpAddPostCurrFile("DocContent", "");
					var returnValue = webObj.HttpPost(uploadContext
							+ '/FileUploadServlet'); // 判断上传是否成功
					var obj = Ext.util.JSON.decode(returnValue);
					if ("true" == obj.success) {
						alert("文件保存成功");
						Ext.getCmp("fileListGrid").reloadList();
					} else
						alert("文件保存失败");
				} catch (e) {
					alert("异常\r\nError:" + e + "\r\nError Code:" + e.number
							+ "\r\nError Des:" + e.description);
				}

			},

			/*
			 * 处理“返回”点击事件
			 */
			handleBack : function() {
				Ext.getCmp("createDocWindow").close();
				try {
					document.all.WebOfficeObj.Close();
				} catch (ex) {
				}
			},

			// private
			initComponent : function() {
				zr.dms.createDocWindow.superclass.initComponent.call(this);
				this.addEvents(
						/**
						 * @event okClicked 当确定按钮被点击时触发
						 * @param {zr.dms.createDocWindow}
						 *            this
						 */
						'okClicked',
						/**
						 * @event okClicked 当取消按钮被点击时触发
						 * @param {zr.dms.createDocWindow}
						 *            this
						 */
						'cancelClicked');
			}

		});

/**
 * 新建文件夹窗口
 */
zr.dms.CreateFolderWindow = function(config) {

	// 将字段加入到form中，以利用form进行样式排列
	this.createForm = new Ext.FormPanel({
				labelWidth : 50,
				labelAlign : 'right',
				url : '',
				bodyStyle : 'padding:10px 10px 0',
				autoScroll : false,
				items : [new Ext.form.TextField({
									fieldLabel : '名称',
									// name : 'COL_FOLDERNAME',
									name : 'filename',
									allowBlank : false,
									width : 150,
									maxLength : 32
								}), new Ext.form.TextField({
									fieldLabel : '描述',
									// name : 'COL_FOLDERSUMMARY',
									name : 'summary',
									width : 150,
									maxLength : 32
								}), new Ext.form.TextField({
									hidden : true,
									width : 10,
									name : 'id'
								}), new Ext.form.TextField({
									hidden : true,
									width : 10,
									name : 'objid'
								})]
			});

	Ext.apply(this, config);
	zr.dms.CreateFolderWindow.superclass.constructor.call(this, {
				id : 'createFolderWindow',
				closeAction : 'hide',
				layout : 'fit',
				width : 260,
				height : 150,
				modal : true,
				title : '新建文件夹',
				items : this.createForm,
				buttons : [{
							text : '确定',
							handler : function(button, e) {
								this.doCreate(e);
							},
							scope : this
						}, {
							text : '取消',
							handler : function(button, e) {
								this.resetInput();
								this.fireEvent('cancelClicked', this, e);
								if (this.cancelHandler) {
									this.cancelHandler.call(this.scope || this,
											this, e);
								} else {
									this.hide();
								}
							},
							scope : this
						}]
			});
};

Ext.extend(zr.dms.CreateFolderWindow, Ext.Window, {
	/** 当前所在目录id */
	catId : null,
	/** 当前所在目录名字 */
	catName : null,
	/** 新建表单 */
	createForm : null,
	/** 确定按钮事件处理器 */
	okHandler : null,
	/** 取消按钮事件处理器 */
	cancelHandler : null,
	/** 事件触发时对象的工作域 */
	scope : null,

	/**
	 * 显示窗口
	 */
	showWindow : function(catId, catName, actionType, record) {
		this.catId = catId;
		this.catName = catName;
		if (catId == '0') {
			this.catName = '我的文档';
		}
		this.show();
		var form = this.createForm.getForm();
		if (actionType == "edit") {
			form.loadRecord(record);
		} else {

			form.reset();
		}

	},

	/**
	 * 将输入框清空
	 */
	resetInput : function() {
		var form = this.createForm.getForm();
		form.reset();
	},

	/**
	 * 新建单位
	 */
	doCreate : function(event) {
		var form = this.createForm.getForm();
		if (this.catId == "") {
			this.catId = "-1";
		}
		if (form.isValid()) {
			form.submit({
				url : context + '/app/dms.do?method=save',
				waitMsg : '保存中...',
				method : 'POST',/**/
				params : {
					COL_FOLDERICON : 'FOLDER',
					COL_PARENTFOLDERID : this.catId,
					objkey : 'FOLDER',
					okey : 'FOLDER'
				},
				scope : this,
				success : function(form, action) {
					// var obj =
					// Ext.util.JSON.decode(action.response.responseText);
					//Ext.Msg.alert('', '保存成功');
					this.resetInput();
					// 执行确定处理
					this.fireEvent('okClicked', this);
					if (this.okHandler) {
						this.okHandler.call(this.scope || this, this, event);
					} else {
						this.hide();
					}

					form.responseText; // 返回的结果
				},
				failure : function(form, action) {
					if (action.failureType === Ext.form.Action.CONNECT_FAILURE) {
						Ext.Msg.alert('保存失败', 'Status:'
										+ action.response.status + ': '
										+ action.response.statusText);
					}
					if (action.failureType === Ext.form.Action.SERVER_INVALID) {
						// server responded with success = false
						Ext.Msg.alert('保存失败', action.result.errors.errormsg);
					}

				}
			});

		} else {
			Ext.MessageBox.alert('错误', '请修正非法数据后再保存！');
			return;
		}
	},

	// private
	initComponent : function() {
		zr.dms.CreateFolderWindow.superclass.initComponent.call(this);
		this.addEvents(
				/**
				 * @event okClicked 当确定按钮被点击时触发
				 * @param {zr.dms.CreateFolderWindow}
				 *            this
				 */
				'okClicked',
				/**
				 * @event okClicked 当取消按钮被点击时触发
				 * @param {zr.dms.CreateFolderWindow}
				 *            this
				 */
				'cancelClicked');
	}

});

/**
 * 地址栏
 */
zr.dms.AddressBar = function(config) {
	var proxy = new Ext.data.HttpProxy({
				url : context + '/app/dms.do?method=getFolderList'
			});
	proxy.on('beforeload', function(proxy, params) {
				var query = params.query;

				params.args = [query];
				params.pathId = this.pathId;
				params.pathName = this.pathName;
			}, this);

	var addressDs = new Ext.data.Store({
				proxy : proxy,
				reader : new Ext.data.JsonReader({
							root : 'list',
							totalProperty : 'totalCount',
							id : 'id'
						}, [{
									name : 'id',
									type : 'string'
								}, {
									name : 'code',
									type : 'string'
								}, {
									name : 'name',
									type : 'string'
								}, {
									name : 'fullpathId',
									type : 'string'
								}, {
									name : 'fullpath',
									type : 'string'
								}])
			});
	this.addressBox = new Ext.form.ComboBox({
				width : 600,
				editable : true,
				minChars : 1,
				forceSelection : false,
				mode : 'remote',
				store : addressDs,
				triggerAction : 'query',
				typeAhead : false,
				queryParam : 'query',
				displayField : 'fullpath',
				valueField : 'fullpathId',
				hiddenName : 'fullpathId'
			});
	this.addressBox.on('select', function(combo, record, index) {
				// 执行跳转处理
				this.fireEvent('goClicked', this);
				if (this.goHandler) {
					this.goHandler.call(this.scope || this, this, e);
				}
			}, this);

	Ext.apply(this, config);
	zr.dms.AddressBar.superclass.constructor.call(this, {
				id : 'addressBar',
				items : ['文档目录地址:', this.addressBox, /*
													 * new Ext.Button({ icon :
													 * context +
													 * '/resources/ext3/resources/images/right2.gif',
													 * iconCls :
													 * 'x-btn-text-icon', text :
													 * '转到', handler :
													 * function(button, e) { //
													 * 执行跳转处理
													 * this.fireEvent('goClicked',
													 * this); if
													 * (this.goHandler) {
													 * this.goHandler.call(this.scope ||
													 * this, this, e); } },
													 * scope : this }),
													 */
								'-',new Ext.form.TextField({
									id : 'queryText',
									width : 200,
									emptyText : '请输入文档名称'
								}), ' ',new Ext.Button({
									icon : context
											+ '/app/dms/images/search.gif',
									iconCls : 'x-btn-text-icon',
									text : '搜索',
									handler : function(button, e) {
										// 执行查询
										this.fireEvent('queryClicked', this);
										if (this.goHandler) {
											this.goHandler.call(this.scope
															|| this, this, e);
										}
									},
									scope : this
								}),'-', new Ext.Button({
									text : '高级搜索',
									icon : context
											+ '/app/dms/images/searchs.gif',
									iconCls : 'x-btn-text-icon',
									handler : function(button, e) {
										detailQuery(this, e);
									},
									scope : this
								},{xtype: 'tbfill'})]
			});
};

Ext.extend(zr.dms.AddressBar, Ext.Toolbar, {
			/** 当前所在路径id */
			pathId : null,
			/** 当前所在路径名称 */
			pathName : null,
			/** 确定按钮事件处理器 */
			goHandler : null,
			/** 事件触发时对象的工作域 */
			scope : null,

			/** 地址栏 */
			addressBox : null,
			/**
			 * 设置当前工作路径
			 */
			setAddress : function(id, name) {
				this.pathId = id;
				this.pathName = name;
				this.addressBox.setValue(name);
			},

			/**
			 * 返回当前输入的路径
			 */
			getAddress : function() {
				return this.addressBox.getValue();
			},
			
			/**
			 * 获取地址栏
			 * @return {}
			 */
			getAddressBox : function(){
				return this.addressBox;
			},
			
			/**
			 * 获取地址显示值
			 * @return {}
			 */
			getAddressText : function(){
				return this.addressBox.getRawValue();
			},

			// private
			initComponent : function() {
				zr.dms.AddressBar.superclass.initComponent.call(this);
				this.addEvents(
						/**
						 * @event goClicked 当转到按钮被点击时触发
						 * @param {zr.dms.AddressBar}
						 *            this
						 */
						'goClicked');
				this.addEvents(
						/**
						 * @event queryClicked 当搜索按钮被点击时触发
						 * @param {zr.dms.AddressBar}
						 *            this
						 */
						'queryClicked');
				this.addEvents(
						/**
						 * @event queryClicked 当搜索按钮被点击时触发
						 * @param {zr.dms.AddressBar}
						 *            this
						 */
						'onSQueryClicked');
			}

		});
